package com.example.knowledge.mvvm.activity
import android.content.Context
import android.content.Intent
import android.widget.TextView
import androidx.lifecycle.Observer
import com.example.knowledge.R
import com.example.knowledge.mvvm.viewmodel.ReportDetailViewModel
import com.gsafety.libraryktx.base.BaseActivity
import com.gsafety.libraryktx.config.Constant
import com.gsafety.libraryktx.expand.create
import kotlinx.android.synthetic.main.know_report_activity_detail.*

/**报告详情
 * @author : lj
 * @date : 2021/1/20 11:09
 */
class ReportDetailActivity: BaseActivity(){
    private lateinit var mv: ReportDetailViewModel
    override fun initView() {
        initmodel()
        var reportId = intent.getStringExtra(Constant.Extra_ID_KEY)
        var title=intent.getStringExtra(Constant.Extra_TITLE_KEY)
        findViewById<TextView>(R.id.title_name).text =title
        mv.requestriskReport(reportId)
    }

    override fun initData() {

    }

    override fun getLayoutId(): Int {
      return R.layout.know_report_activity_detail
    }
    private fun initmodel() {
        mv = ReportDetailViewModel()
        mv = create(ReportDetailViewModel::class)
        mv.mReportRiskValue.observe(this, Observer {
            web.loadUrl(this,it.fileUrl)
        })
    }
    companion object {
        fun startIntent(ctx: Context, id:String,  name:String) {
            var intent=Intent()
            intent.setClass(ctx, ReportDetailActivity::class.java)
            intent.putExtra(Constant.Extra_ID_KEY,id)
            intent.putExtra(Constant.Extra_TITLE_KEY,name)
            ctx.startActivity(intent)
        }
    }
}